package org.xdq.守护线程;

public class Test {

    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            for(;;){
                System.out.println("守护线程运行中......");
               try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        t1.setDaemon(true);//设置为守护线程

        t1.start();

        new Thread(()->{
            for(int i=1;i<=1000;i++){
                System.out.println("===>"+i);
                try {
                    Thread.sleep(20);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();


    }
}
